package middle;

import java.util.*;

/**
 * ZJ8 用户喜好
 * @author d3y1
 */
public class ZJ8{
    private static int[] likes;
    private static HashMap<Integer, List<Integer>> likeMap;

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        while(in.hasNext()){
            solution1(in);
            solution2(in);
        }
    }

    /**
     * 模拟法: 二分优化
     * @param in
     */
    private static void solution1(Scanner in){
        int n = in.nextInt();
        likes = new int[n+1];
        likeMap = new HashMap<>();

        int like;
        List<Integer> list;
        for(int i=1; i<=n; i++){
            like = in.nextInt();
            list = likeMap.get(like);
            if(list != null){
                list.add(i);
                likeMap.put(like, list);
            }else{
                likeMap.put(like, new ArrayList<>(Collections.singletonList(i)));
            }
        }

        int queries = in.nextInt();
        int left, right, k;
        for(int i=1; i<=queries; i++){
            left = in.nextInt();
            right = in.nextInt();
            k = in.nextInt();
            System.out.println(query(left, right, k));
        }
    }

    private static int query(int left, int right, int k){
        int count = 0;

        List<Integer> list = likeMap.get(k);
        if(list == null){
            return 0;
        }
        // 寻找第一个大于等于left的索引
        else{
            int l = 0;
            int r = list.size()-1;
            while(l <= r){
                int mid = (l+r)>>1;
                if(list.get(mid) > left) {
                    r = mid-1;
                }else if((list.get(mid) < left)){
                    l = mid+1;
                }else{
                    l = mid;
                    break;
                }
            }

            for(int i=l; i<list.size(); i++){
                if(list.get(i) <= right){
                    count++;
                }
            }
            return count;
        }
    }


    /**
     * 模拟法: 暴力法
     * @param in
     */
    private static void solution2(Scanner in){
        int n = in.nextInt();
        likes = new int[n+1];

        for(int i=1; i<=n; i++){
            likes[i] = in.nextInt();
        }

        int queries = in.nextInt();

        int left, right, k;
        for(int i=1; i<=queries; i++){
            left = in.nextInt();
            right = in.nextInt();
            k = in.nextInt();
            System.out.println(find(left, right, k));
        }
    }

    private static int find(int left, int right, int k){
        int count = 0;
        for(int i=left; i<=right; i++){
            if(likes[i] == k){
                count++;
            }
        }

        return count;
    }
}